package Day05;
import java.util.Scanner;
public class Addition {
    public static void main(String[] args) {
        Scanner input1 = new Scanner(System.in);
        int num1,num2,sum,score = 0,result;
        for (int i=1;i<=10;i++) {
            System.out.println("请看第"+i+"题：");
            num1 = (int)(Math.random()*100)+1;
            num2 = (int)(Math.random()*100)+1;
            result = num1 + num2;
            System.out.print(num1+"+"+num2+"=");
            sum = input1.nextInt();
            if (sum==result) {
                System.out.println("答对了！");
                score += 10;
            } else {
                System.out.println("答错了！请重新作答！");
                for (;;) {
                    System.out.print(num1+"+"+num2+"=");
                    sum = input1.nextInt();
                    if (sum==result) {
                        System.out.println("答对了！");
                        break;
                    } else {
                        System.out.println("答错了！请重新作答！");
                    }
                }
            }
        }
        System.out.println("总分为："+score+"分！");
    }
}
